package org.fyv233.missingno_craft.block;

import net.minecraft.block.*;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import org.fyv233.missingno_craft.Missingno_craft;

public class ModBlocks {

    public static final Block MISSINGNO_BLOCK = register("missingno_block", new Block(AbstractBlock.Settings.create().strength(6.0f, 6.0f).requiresTool()));
    public static final Block MISSINGNO_ORE = register("missingno_ore", new Block(AbstractBlock.Settings.create().strength(4.0f, 4.0f).requiresTool()));

    public static final Block MISSINGNO_STAIRS = register("missingno_stairs",
            new StairsBlock(MISSINGNO_BLOCK.getDefaultState(), AbstractBlock.Settings.copy(MISSINGNO_BLOCK)));
    public static final Block MISSINGNO_SLABS = register("missingno_slabs",
            new SlabBlock(AbstractBlock.Settings.copy(MISSINGNO_BLOCK)));
    public static final Block MISSINGNO_BUTTON = register("missingno_button",
            new ButtonBlock(BlockSetType.OAK, 5, AbstractBlock.Settings.copy(MISSINGNO_BLOCK)));
    public static final Block MISSINGNO_FENCE = register("missingno_fence",
            new FenceBlock(AbstractBlock.Settings.copy(MISSINGNO_BLOCK)));
    public static final Block MISSINGNO_FENCE_GATE = register("missingno_fence_gate",
        new FenceGateBlock(WoodType.OAK, AbstractBlock.Settings.copy(MISSINGNO_BLOCK)));

    public static Block register(String id, Block block) {
        registerBlockItems(id, block);
        return Registry.register(Registries.BLOCK, Identifier.of(Missingno_craft.MOD_ID, id), block);
    }

    public static void registerBlockItems(String id, Block block) {
        Item item = Registry.register(Registries.ITEM, Identifier.of(Missingno_craft.MOD_ID, id), new BlockItem(block, new Item.Settings()));
        if (item instanceof BlockItem) {
            ((BlockItem)item).appendBlocks(Item.BLOCK_ITEMS, item);
        }
    }

    public static void registerModBlocks() {}

}
